package sys.spvisor.core.service.project;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import sys.spvisor.core.dao.project.TProjectPeopleMapper;
import sys.spvisor.core.dao.project.TQuestionMapper;
import sys.spvisor.core.entity.project.TQuestion;
import sys.spvisor.core.entity.project.TQuestionExample;
import sys.spvisor.core.entity.project.TQuestionExample.Criteria;

@Service
public class QuestionService {
	
	@Autowired
	TQuestionMapper tQuestionMapper;
	@Autowired
	TProjectPeopleMapper tProjectPeopleMapper;
	
	//插入问题
	public int addQuetion(TQuestion record) {
		int rows = tQuestionMapper.insert(record);
		return rows;
	}
	
	//查找项目中的问题
	public List<TQuestion> findQuestionsByProId(int proId) {
		TQuestionExample example = new TQuestionExample();
		Criteria criteria = example.createCriteria();
		criteria.andProIdEqualTo(proId);
		List<TQuestion> lists = tQuestionMapper.selectByExample(example);
		return lists;
	}
	
	//查找所有的问题
	public List<TQuestion> findAllQuestions() {
		TQuestionExample example = new TQuestionExample();
		List<TQuestion> lists = tQuestionMapper.selectByExample(example);
		return lists;
	}
	
	//修改问题
	public void updateQuetion(TQuestion record) {
		tQuestionMapper.updateByPrimaryKey(record);
	}
}
